package gameManager;
import java.io.File;
import java.util.List;
import javax.swing.JFileChooser;

public abstract class PlayRecordManager{
    private Player currentPlayer;
    private List<Player> playerFile;

        public PlayRecordManager(){
           playerFile = loadPlayer(chooseFile());
           playerLogin();
           setcurrentPlayer(playerLogin());
        }

        public File chooseFile () {
            File returnFile = null;
            JFileChooser chooser = new JFileChooser(System.getProperties().getProperty("user.dir"));
            int response = chooser.showOpenDialog(null);
            if (response == JFileChooser.APPROVE_OPTION) {
                returnFile = chooser.getSelectedFile();
            }
            return returnFile;
        }

        public abstract List<Player> loadPlayer(File playerFile);
        
        public abstract void updateRecord();
        
        public List<Player> getPlayer(){
            return playerFile;
        }

        public abstract Player playerLogin();

        public Player getCurrentPlayer(){
        return currentPlayer;
        }

        public void setcurrentPlayer(Player player){
        currentPlayer=player;
        }
}